package com.tuomaxu.service.impl;

import com.tuomaxu.service.IDMailServce;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

@Service
public class MailServceImpl implements IDMailServce {

    @Autowired
    private JavaMailSender javaMailSender;

    public boolean send(String email,String code){

        SimpleMailMessage message = new SimpleMailMessage();
        message.setSubject("登录验证码");
        message.setFrom("tuomaxu@qq.com");
        message.setTo(email);
        message.setText("验证码："+code);
        try {
            System.out.println("验证码:"+code);
//            javaMailSender.send(message);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return  false;
        }
    }
}
